//
//  InfoPhotoViewController.m
//  时尚男士
//
//  Created by dlios on 15-6-10.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "InfoPhotoViewController.h"
#import "PhotoCollectionViewCell.h"
#import "UIImageView+AFNetworking.h"
#import "InfoPhoto.h"
#import "AFNetworking.h"
#import "PhoCollectionCell.h"

#define PHOTOS_REUSEID @"PhotosReuse"
@interface InfoPhotoViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UITextViewDelegate>

@property (nonatomic, retain) NSMutableArray *photosArr;//装图片的数组
@property (nonatomic, retain) UICollectionView *collectionView;//平铺图
@property (nonatomic, retain) UICollectionView *collection;//相册视图
@property (nonatomic, assign) NSInteger oneNum;
@property (nonatomic, retain) UILabel *OneLabel;
@property (nonatomic, retain) UIView *OneView;
@property (nonatomic, retain) UILabel *TwoLabel;
@property (nonatomic, retain) UIView *TwoView;
@property (nonatomic, retain) UILabel *ThreeLabel;
@property (nonatomic, retain) UITextView *OneText;

@property (nonatomic, retain) NSMutableArray *arr;
@property (nonatomic, retain) NSMutableDictionary *dic;

@end

@implementation InfoPhotoViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.photosArr = [NSMutableArray arrayWithObjects:self.photoUrl, nil];
    
    //平铺图
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    flowLayout.itemSize = CGSizeMake((self.view.bounds.size.width), (self.view.bounds.size.width));
    flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;//滚动方向
    flowLayout.minimumLineSpacing = 3;//最小行间距
    flowLayout.sectionInset = UIEdgeInsetsMake(-120, 0, 3, 0);
    flowLayout.minimumInteritemSpacing = 3;//最小item的间距
    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height) collectionViewLayout:flowLayout];
    _collectionView.backgroundColor = [UIColor blackColor];
    _collectionView.delegate = self;
    _collectionView.dataSource = self;
    
    [self.view addSubview:self.collectionView];
    [_collectionView release];
    [_collectionView registerClass:[PhotoCollectionViewCell class] forCellWithReuseIdentifier:PHOTOS_REUSEID];
    
    //相册
    UICollectionViewFlowLayout *flowLayoutTwo = [[UICollectionViewFlowLayout alloc] init];
    flowLayoutTwo.itemSize = CGSizeMake(self.view.bounds.size.width, self.view.bounds.size.height);
    //滚动方向
    flowLayoutTwo.scrollDirection = UICollectionViewScrollDirectionVertical;
    //最小行间距
    flowLayoutTwo.minimumInteritemSpacing = 0;
    
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.photosArr.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
        PhotoCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:PHOTOS_REUSEID forIndexPath:indexPath];
        
        NSURL *url = [NSURL URLWithString:self.photoUrl];
        [cell.myImage setImageWithURL:url];
        return cell;
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    NSInteger i = self.collectionView.contentOffset.x / self.collectionView.frame.size.width;
    InfoPhoto *pho = [self.photosArr objectAtIndex:i];
    [self.photosArr objectAtIndex:i];
}

- (void)dealloc
{
    [_photoUrl release];
    [_photosArr release];
    [_photoLabel release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
